<div align="center">
  <h1><%= @transaction_type.capitalize %> Statistics</h1>
  
    <div id="canvas">
      <canvas id="myChart"></canvas>
    </div>
	    
	<script src="javascripts/chart/Chart.js"></script>
	<script src="javascripts/chart/data-chart.js"></script>
	<script>data = setGetData(<%=@dates%>, <%=@data%>)</script>
	<script src="javascripts/chart/view-chart.js"></script>    
	    
  	<br>

  <% if @stats.empty? %>
    <h4>You don't have <%= @transaction_type %> in this period</h4>
  <% else %>
  	<table class="table" align="center" border="1">
	  <tr>
	    <th>Name</th>
	    <th>Amount</th>
	    <th>Date</th>
	
	    <% @stats.each do |s| %>
	      <tr>
	        <td><%= s.get_name %></td>
	        <td><%="$#{s.amount}"%></td>
	        <td><%= s.pay_date.to_date %></td>
	        <!-- <td><#%= link_to 'Remove', pay, :confirm => 'Are you sure?', :method => :delete %></td> -->
	      </tr>
	    <% end %>
	    
	  </tr>
	</table>
	
	<h4>Total: $<%= @total %></h4>
  <% end %>

  <a href="/coming_expirations"><button class="btn">Return</button></a>
  
  <form action="stats" method="get" id="stats">
  	<p>View how many payments or incomes I did in a given period of time</p>
  	From date <input type="date" id="from_date" name="from_date" value="<%= @from_date %>" />
  	To date <input type="date" id="to_date" name="to_date" value="<%= @to_date %>" />
  	Type <select name="type" id="type">
  		<option value="1">Payments</option>
		<option value="0">Incomes</option>
	</select>
    <input type="submit" value="View stats" id="viewStatsButton" />
  </form>
</div>
